{% extends 'base.html' %}

{% block title %}{{ project.name }} - 项目详情{% endblock %}

{% block content %}
<div class="card">
  <div class="card-header card-header-flex">
    <h5>项目详情</h5>
    <div>
      <a href="{{ url_for('project_list') }}" class="btn btn-secondary">
        <i class="fas fa-arrow-left"></i> 返回列表
      </a>
      <a href="{{ url_for('project_edit', project_id=project.id) }}" class="btn btn-warning">
        <i class="fas fa-edit"></i> 编辑项目
      </a>
    </div>
  </div>
  <div class="card-body">
    <div class="table-responsive">
      <table class="table table-bordered table-hover">
        <tbody>
          <tr>
            <th style="width: 150px;" class="bg-light">项目名称</th>
            <td>{{ project.name }}</td>
          </tr>
          <tr>
            <th class="bg-light">项目代码</th>
            <td>{{ project.code }}</td>
          </tr>
          <tr>
            <th class="bg-light">项目分类</th>
            <td>{{ project.category_name }}</td>
          </tr>
          <tr>
            <th class="bg-light">项目状态</th>
            <td>
              <span class="badge badge-primary">{{ project.status_name }}</span>
            </td>
          </tr>
          <tr>
            <th class="bg-light">GitLab地址</th>
            <td>{% if project.git_url %}<a href="{{ project.git_url }}" target="_blank">{{ project.git_url }}</a>{% else %}<span class="text-muted">未设置</span>{% endif %}</td>
          </tr>
          <tr>
            <th class="bg-light">项目描述</th>
            <td>{{ project.description or '<span class="text-muted">无</span>' | safe }}</td>
          </tr>
          <tr>
            <th class="bg-light">创建人</th>
            <td>{{ project.creator or '<span class="text-muted">未知</span>' | safe }}</td>
          </tr>
          <tr>
            <th class="bg-light">创建时间</th>
            <td>{{ project.create_time or '<span class="text-muted">未知</span>' | safe }}</td>
          </tr>
          <tr>
            <th class="bg-light">最后更新人</th>
            <td>{{ project.updater or '<span class="text-muted">未知</span>' | safe }}</td>
          </tr>
          <tr>
            <th class="bg-light">更新时间</th>
            <td>{{ project.update_time or '<span class="text-muted">未知</span>' | safe }}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

<div class="card mt-4">
  <div class="card-header card-header-flex">
    <h5>部署信息</h5>
    <a href="{{ url_for('deployment_edit', project_id=project.id) }}" class="btn btn-primary">
      <i class="fas fa-plus"></i> 添加部署信息
    </a>
  </div>
  <div class="card-body">
    <div class="table-responsive">
      <table class="table table-bordered table-hover">
        <thead>
          <tr>
            <th style="width: 60px;">ID</th>
            <th>部署类型</th>
            <th>主机IP</th>
            <th>登录用户</th>
            <th>部署目录</th>
            <th style="width: 150px;" class="text-center">操作</th>
          </tr>
        </thead>
        <tbody>
          {% for deploy in deployments %}
          <tr>
            <td>{{ deploy.id }}</td>
            <td>{{ deploy.deploy_type_name }}</td>
            <td>{{ deploy.host_ip }}</td>
            <td>{{ deploy.username or '<span class="text-muted">无</span>' | safe }}</td>
            <td>{{ deploy.directory }}</td>
            <td class="text-center">
              <div class="btn-action-group">
                <a href="{{ url_for('deployment_edit', deployment_id=deploy.id) }}" class="btn btn-sm btn-warning">
                  <i class="fas fa-edit"></i><span class="btn-text">编辑</span>
                </a>
                <form class="inline-form" method="post" action="{{ url_for('deployment_delete', deployment_id=deploy.id) }}">
                  <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除此部署信息吗？')">
                    <i class="fas fa-trash"></i><span class="btn-text">删除</span>
                  </button>
                </form>
              </div>
            </td>
          </tr>
          {% else %}
          <tr>
            <td colspan="6" class="text-center text-muted">暂无部署信息</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %} 